package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppMingxiFreetime;
import com.vf.admin.miaodong.entity.AppMingxiJinbi;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 账单明细-免费时长
 */
@Repository
public class AppMingxiFreetimeDao extends BaseDao<AppMingxiFreetime> {

    /**
     * 查询列表
     */
    public List<AppMingxiFreetime> findList(Integer userid, SplitPageBean splitPage) {
        ArrayList<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_mingxi_freetime where 1=1  ");
        sbStr.append(" and userid=? ");
        paramList.add(userid);
        sbStr.append(" order by createtime desc");
        String sql = sbStr.toString();
        return this.queryList(sql,paramList, AppMingxiFreetime.class,splitPage);
    }


    /**
     * 详情
     */
    public AppMingxiFreetime get(Integer id) {
        if (StringEx.isNullOrLing(id)) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_mingxi_freetime where 1=1");
        sbStr.append(" and id = ? ");
        paramList.add(id);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppMingxiFreetime.class);
    }

    /**
     * 添加/修改
     */
    public void save(AppMingxiFreetime haoYou) {
        if (haoYou.getId() != null && haoYou.getId() > 0) {
            this.update(haoYou);
        } else {
            haoYou.setId(this.add(haoYou));
        }
    }

}
